DECLARE    
    @Server1  Varchar(200)
    ,@Server2  Varchar(200)
    ,@TestDatabase Varchar(200)
    
SELECT @Server1 = 'Server1'
SELECT @Server2 = 'Server2'
SELECT @TestDatabase = 'Adventure Works DW 2008 Enterprise'



-- Insert Server Data ************************************************************************************************************


IF NOT EXISTS(SELECT * FROM [Server] WHERE ServerID = 1)
BEGIN
   
   INSERT INTO [Server](ServerID,Name,URL,Disabled,Offline,Load)
   SELECT 1, @Server1,'http://'+ @Server1 +'/olap/msmdpump.dll',0,0,0

   RAISERROR('ServerID 1 has been inserted into the server table',0,1) WITH NOWAIT

END
ELSE
   RAISERROR('ServerID 1 already exists in the server table',0,1) WITH NOWAIT
   
   
IF NOT EXISTS(SELECT * FROM [Server] WHERE ServerID = 2)
BEGIN
   
   INSERT INTO [Server](ServerID,Name,URL,Disabled,Offline,Load)
   SELECT 2, @Server2,'http://'+ @Server2 +'/olap/msmdpump.dll',0,0,0

   RAISERROR('ServerID 2 has been inserted into the server table',0,1) WITH NOWAIT
   
END
ELSE
   RAISERROR('ServerID 2 already exists in the server table',0,1) WITH NOWAIT
   
   
-- Insert Database ******************************************************************************************************************
IF NOT EXISTS (SELECT * FROM [Database] WHERE DatabaseID = 1)
BEGIN
	INSERT INTO [Database](DatabaseID, Name, Disabled)
	VALUES(1,@TestDatabase,0 ) 
END
ELSE
BEGIN
   RAISERROR('Seed data already exists for DatabaseID 1, so not reinserting..',0,1) WITH NOWAIT   
END

-- Insert ServerDatabase **********************************************************************

IF NOT EXISTS (SELECT * FROM [ServerDatabase] WHERE ServerID = 1 and DatabaseID = 1)
BEGIN
	INSERT INTO [ServerDatabase](ServerID, DatabaseID, Disabled)
	VALUES(1,1,0 ) 
END
ELSE
BEGIN
   RAISERROR('Seed data already exists for DatabaseID 1 and ServerID = 1, so not reinserting..',0,1) WITH NOWAIT   
END

IF NOT EXISTS (SELECT * FROM [ServerDatabase] WHERE ServerID = 1 and DatabaseID = 2)
BEGIN
	INSERT INTO [ServerDatabase](ServerID, DatabaseID, Disabled)
	VALUES(2,1,0 ) 
END
ELSE
BEGIN
   RAISERROR('Seed data already exists for DatabaseID 1 and ServerID = 2, so not reinserting..',0,1) WITH NOWAIT   
END